package com.example.shengyin.service.impl;

import com.example.shengyin.dao.JobMapper;
import com.example.shengyin.entity.Job;
import com.example.shengyin.entity.Page;
import com.example.shengyin.service.JobService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobServiceImpl implements JobService {

    @Autowired
    private JobMapper jobMapper;

    @Override
    public Job selectById(Integer id) {
        return jobMapper.selectById(id);
    }

    @Override
    public int insert(Job job) {
        return jobMapper.insert(job);
    }

    @Override
    public int update(Job job) {
        return jobMapper.update(job);
    }



    @Override
    public int deleteById(Integer id) {
        return jobMapper.deleteById(id);
    }

    @Override
    public int deleteByIds(String ids) {
        return jobMapper.deleteByIds(ids);
    }

    @Override
    public Page jobList(@Param("page") int page2, @Param("limit") int limit, @Param("jobtitle") String jobtitle, @Param("pos") String pos,
                        @Param("jobtype") String jobtype, @Param("pt") String pt){
        List<Job> jobs = jobMapper.jobList(page2, limit, jobtitle, pos, jobtype, pt);
        int countTotall = jobMapper.countTotall(jobtitle, pos, jobtype, pt);

         return new Page(jobs,page2,countTotall,limit);
    };

//    public List<Job> jobList(@Param("page")int page, @Param("limit")int limit, String jobtitle, String pos, String jobtype, String pt) {
//        return jobMapper.jobList((page-1)*limit,limit,jobtitle,pos,jobtype,pt);
//    }

    @Override
    public int countTotall(String jobtitle, String pos, String jobtype, String pt) {
        return jobMapper.countTotall(jobtitle,pos,jobtype,pt);
    }


    @Override
    public Job selResumeByJobId(Integer id) {
        return jobMapper.selResumeByJobId(id);
    }



    /**
     public List<Admin> list(Page page, String uname, String phone, String realname, String pos, String roles, Timestamp start, Timestamp end) {
     return dao.list((page.getPage() - 1) * page.getLimit(), page.getLimit(), uname, phone, realname, pos, roles, start, end);
     }

     public int count(String uname, String phone, String realname, String pos, String roles, Timestamp start, Timestamp end) {
     return dao.count(uname, phone, realname, pos, roles, start, end);
     }
     */
}
